home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1995 February
/
1995-02b.d64
/
money functions
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
1KB
|
35 lines
100 :
110 rem money functions on dollars
120 :
130 rem note they may be innaccurate on large numbers due to round-off
140 rem rd(x) rounds up or down to a full cent
150 rem rs(x) raises to next full cent if there's a fraction of a cent
160 rem tr(x) truncates, or lops off any fraction of a cent
170 rem fr(x) returns only fraction of a cent
180 :
190 def fn rd(x)=int(x*100+.5)/100
200 :
210 def fn rs(x)=int(x*100+.9999)/100
220 :
230 def fn tr(x)=int(x*100)/100
240 :
250 def fn fr(x)=x-int(x*100)/100
260 :
270 :
280 :
290 rem money functions on pennies
300 :
310 rem no roundoff errors, but the values are pennies, not dollars
320 rem rd(x) rounds up or down to a full cent
330 rem rs(x) raises to next full cent if there's a fraction of a cent
340 rem tr(x) truncates, or lops off any fraction of a cent
350 rem fr(x) returns only fraction of a cent
360 :
370 def fn rd(x)=int(x+.5)
380 :
390 def fn rs(x)=int(x+.99999)
400 :
410 def fn tr(x)=int(x)
420 :
430 def fn fr(x)=x-int(x)